package cn.leyou.advice;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author 21195
 * @version v1.0
 * @package cn.leyou.advice
 * @description:
 * @date 2019/6/22 21:49
 **/
@ControllerAdvice
@Slf4j
public class BasicExceptionAdvice {
    @ExceptionHandler(RuntimeException.class)
    public ResponseEntity<String> handleException(RuntimeException e){
        //我们暂定返回状态为400，然后从异常中获取友好提示信息
        return ResponseEntity.status(400).body(e.getMessage());

    }
}
